-module(cookie).
-export([check_cookie/1]).
-include_lib("yaws/include/yaws_api.hrl").


check_cookie(A) ->
	H = A#arg.headers,
	case yaws_api:find_cookie_val("web_sid", H#headers.cookie) of
		[] ->
			{error, nocookie};
		Val ->
         case yaws_api:cookieval_to_opaque(Val) of
             {ok, Sess} ->
                 {ok, Sess, Val};
             {error, {has_session, Sess}} ->
                 {ok, Sess};
             Else ->
                 Else
         end
	end.
